﻿

starting_prestige = {
	value = {
		# Longer-lived characters start with some inherent prestige.
		add =	{
			value = medium_prestige_value
			multiply = {
				value = 0

				# Bonus for older characters (who have presumably accomplished more).
				if = {
					limit = { age > 12}
					add = 1
				}
				else_if = {
					limit = { age > 24}
					add = 2
				}
				else_if = {
					limit = { age > 36}
					add = 3
				}
				else_if = {
					limit = { age > 48}
					add = 4
				}
				else_if = {
					limit = { age > 60}
					add = 5
				}

				# Bonus/penalty for traits.
				if = {
					limit = {
						OR = {
							has_trait = arrogant
							has_trait = ambitious
						}
					}
					add = 1
				}
				else_if = {
					limit = {
						OR = {
							has_trait = humble
							has_trait = content
						}
					}
					add = -1
				}

				# Humble/content children shouldn't have a prestige penalty!
				min = 0
			}
		}

		# Rulers also gain bonus prestige based on their tier.
		add = {
			value = medium_prestige_value
			multiply = highest_held_title_tier
		}
	}
}

starting_piety = {
	value = {
		# All characters start with some about of piety based on how long they have lived a virtuous life.
		add = {
			value = medium_piety_value
			multiply = {
				add = num_virtuous_traits
				subtract = num_sinful_traits
				if = {
					limit = { has_trait = zealous }
					add = 1
				}
				else_if = {
					limit = { has_trait = cynical }
					add = -1
				}
			}
			multiply = {
				value = 0
				if = {
					limit = { age > 12}
					add = 1
				}
				else_if = {
					limit = { age > 24}
					add = 2
				}
				else_if = {
					limit = { age > 36}
					add = 3
				}
				else_if = {
					limit = { age > 48}
					add = 4
				}
				else_if = {
					limit = { age > 60}
					add = 5
				}
			}
		}

		# Rulers also gain some Piety based on tier (but less than piety than prestige).
		add = {
			value = minor_piety_value
			multiply = highest_held_title_tier
		}

		# Nobody starts with negative piety, not even even sinful characters.
		min = minor_piety_value
	}
}

starting_influence = {
	value = {
		# Longer-lived characters start with some inherent influence.
		add =	{
			value = medium_influence_value
			multiply = {
				value = 0

				# Bonus for older characters (who have presumably had time to establish themselves more).
				if = {
					limit = { age > 12}
					add = 1
				}
				else_if = {
					limit = { age > 24}
					add = 2
				}
				else_if = {
					limit = { age > 36}
					add = 3
				}
				else_if = {
					limit = { age > 48}
					add = 4
				}
				else_if = {
					limit = { age > 60}
					add = 5
				}

				# Bonus/penalty for traits.
				if = {
					limit = {
						OR = {
							has_trait = generous
							has_trait = deceitful
						}
					}
					add = 1
				}
				else_if = {
					limit = {
						OR = {
							has_trait = impatient
							has_trait = trusting
						}
					}
					add = -1
				}

				# Children who are impatient/trusting children shouldn't start with negative influence!
				min = 0
			}
		}

		# Rulers also gain bonus prestige based on their tier.
		add = {
			value = medium_prestige_value
			multiply = highest_held_title_tier
		}
	}
}
# What cultural acceptance should two cultures start with?
# root = culture 1
# scope:culture = culture 2
starting_culture_acceptance = {
	# Cultures start with the baseline as their default acceptance
	value = culture_acceptance_baseline
	
	# Historical one-time increases to Cultural Acceptance (added on top of the baseline)
	# Note: List the cultures in the same order as they appear in script in common\culture\cultures.
	if = {
		limit = { current_date >= 1060.1.1 } # Changes for the 1066 bookmark
		if = {
			limit = { # The Ghaznavids have ruled over Afghan land for a few generations - Let's help them keep it
				this = culture:afghan
				scope:culture = culture:turkish
			}
			add = 25
		}
		if = {
			limit = { # The Ghaznavids have ruled over Punjabi land for some time - We don't want them to revolt too quickly
				this = culture:punjabi
				scope:culture = culture:turkish
			}
			add = 20
		}
	}
}

# What cultural acceptance should two cultures drift down towards if above?
# root = culture 1
# scope:culture = culture 2
# this is calculated late in startup after history setup
culture_acceptance_baseline = {
	value = 0
	if = {
		limit = { # To stop errors in observe mode
			exists = root
			exists = scope:culture

			# Set up some scopes we'll need
			trigger_if = {
				limit = {
					culture_number_of_counties > 0
				}
#				calc_culture_dominant_religion = { save_temporary_scope_as = our_religion }
				calc_culture_dominant_faith = { save_temporary_scope_as = our_faith }
			}
			scope:culture = {
				trigger_if = {
					limit = {
						culture_number_of_counties > 0
					}
#					calc_culture_dominant_religion = { save_temporary_scope_as = their_religion }
					calc_culture_dominant_faith = { save_temporary_scope_as = their_faith }
				}
			}
		}
		# Increase base acceptance for sharing the same heritage
		if = {
			limit = {
				has_same_culture_heritage = scope:culture
			}
			add = {
				value = 20 # please update CULTURE_PILLAR_TOOLTIP_HERITAGE_EFFECT if this number changes
				desc = ACCEPTANCE_BASELINE_HERITAGE
			}
		}
		# Increase base acceptance for sharing same language
		if = {
			limit = {
				has_same_culture_language = scope:culture
			}
			add = {
				value = 10 # please update CULTURE_PILLAR_TOOLTIP_LANGUAGE_EFFECT if this number changes
				desc = ACCEPTANCE_BASELINE_LANGUAGE
			}
		}
		# Increase base acceptance for sharing the same ethos if cultures are present within the same geographical area
		if = {
			limit = {
				has_same_culture_ethos = scope:culture
				OR = {
					cultures_share_relevant_region_trigger = yes
					#In case cultures are bordering each other in two different regions
					any_culture_county = {
						any_neighboring_county = {
							culture = scope:culture
						}
					}
				}
			}
			add = {
				value = 10
				desc = ACCEPTANCE_BASELINE_ETHOS
			}
		}
		# General Faith acceptance modifiers
		if = { # Same Religion
			limit = {
				exists = scope:our_religion
				exists = scope:their_religion
				scope:our_religion = scope:their_religion
				root = {
					any_culture_county = {
						percent >= 0.5
						religion = scope:our_religion
					}
				}
				scope:culture = {
					any_culture_county = {
						percent >= 0.5
						religion = scope:our_religion
					}
				}
			}
			add = {
				value = 5
				desc = ACCEPTANCE_BASELINE_RELIGION
			}
		}
		if = { # Same exact Faith
			limit = {
				exists = scope:our_faith
				exists = scope:their_faith
				scope:our_faith = scope:their_faith
				root = {
					any_culture_county = {
						percent >= 0.5
						faith = scope:our_faith
					}
				}
				scope:culture = {
					any_culture_county = {
						percent >= 0.5
						faith = scope:our_faith
					}
				}
			}
			add = {
				value = 10
				desc = ACCEPTANCE_BASELINE_FAITH
			}
		}
		if = { # Eastern faiths
			limit = {
				exists = scope:our_religion
				exists = scope:their_religion
				scope:our_religion = {
					is_in_family = rf_eastern
				}
				scope:their_religion = {
					is_in_family = rf_eastern
				}

				any_culture_county = {
					percent >= 0.5
					title_province = {
						religion = {
							is_in_family = rf_eastern
						}
					}
				}
				scope:culture = {
					any_culture_county = {
						percent >= 0.5
						title_province = {
							religion = {
								is_in_family = rf_eastern
							}
						}
					}
				}
			}
			add = {
				value = 5
				desc = ACCEPTANCE_BASELINE_EASTERN_RELIGION
			}
		}
		if = { # Pluralistic close faiths
			limit = {
				exists = scope:our_faith
				exists = scope:their_faith
				scope:our_faith = {
					has_doctrine = doctrine_pluralism_pluralistic
				}
				scope:their_faith = {
					has_doctrine = doctrine_pluralism_pluralistic
				}
				any_culture_county = {
					percent >= 0.5
					title_province = {
						faith = {
							has_doctrine = doctrine_pluralism_pluralistic
						}
					}
				}
				scope:culture = {
					any_culture_county = {
						percent >= 0.5
						title_province = {
							faith = {
								has_doctrine = doctrine_pluralism_pluralistic
							}
						}
					}
				}
				OR = {
					cultures_share_relevant_region_trigger = yes
					#In case cultures are bordering each other in two different regions
					any_culture_county = {
						any_neighboring_county = {
							culture = scope:culture
						}
					}
				}
			}
			add = {
				value = 10
				desc = ACCEPTANCE_BASELINE_CLOSE_PLURALISTS
			}
		}
	}
}
